package cn.duli.xianer.service.impl;

import cn.duli.xianer.dao.PrivateMsgMapper;
import cn.duli.xianer.pojo.PrivateMsg;
import cn.duli.xianer.service.PrivateMsgService;
import com.github.pagehelper.Page;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class PrivateMsgServiceImpl implements PrivateMsgService {

    @Resource
    private PrivateMsgMapper privateMsgMapper;

    @Override
    public int save(PrivateMsg privateMsg) {
        privateMsgMapper.save(privateMsg);
        return privateMsg.getPmId();
    }

    @Override
    public List<PrivateMsg> findAllByUser(Integer pmUser) {
        return privateMsgMapper.findAllByUser(pmUser);
    }

    @Override
    public PrivateMsg findById(Integer pmId) {
        return privateMsgMapper.findById(pmId);
    }

    @Override
    public Page<PrivateMsg> findByUserAndFriend(Integer pmUser, Integer pmFriend) {
        return privateMsgMapper.findByUserAndFriend(pmUser, pmFriend);
    }

    @Override
    public int findNotReadCount(Integer pmUser, Integer pmFriend) {
        return privateMsgMapper.findNotReadCount(pmUser, pmFriend);
    }

    @Override
    public int updateRead(Integer id) {
        return privateMsgMapper.updateRead(id);
    }

    @Override
    public List<PrivateMsg> findNotRead(Integer pmUser, Integer pmFriend) {
        return privateMsgMapper.findNotRead(pmUser, pmFriend);
    }

    @Override
    public void deleteById(Integer pmId) {
        privateMsgMapper.deleteById(pmId);
    }

    @Override
    public void deleteAll(Integer pmUser, Integer pmFriend) {
        privateMsgMapper.deleteAll(pmUser, pmFriend);
    }

}
